/*delete space in string */
String.prototype.trim = function(){
    return this.replace(/(^\s*)|(\s*$)/g,"");
}
/*erase array element of index*/
Array.prototype.remove = function(index){
    var i = this.indexOf(index);
    if(i>=0) this.splice(i,1);else return false;
}
/*add element to array last*/
Array.prototype.append = function(obj){
    return this[this.length] = obj;
}
/*index what search value in array */
Array.prototype.valueOf = function(value){
    for(var i=0,l=this.length;i<l;i++){
        if(this[i] == value) return i;
    }
    return false;
}
/*get array element value what is max*/
Array.prototype.max = function(){
    var max = this[0];
    for(var i=1,l=this.length;i<l;i++){
        if(this[i]>max) max = this[1];
    }
    return max;
}
/*remove one class is clsName to HTML element*/
HTMLElement.prototype.removeClass = function(clsName){
    var tmp = Function("return /"+clsName+"/;");
    var str = this.className.replace(tmp(),'');
    this.className = str.trim();
}
/*add one class is clsName to HTML element*/
HTMLElement.prototype.pushClass = function(clsName){
    var nameList = this.className + ' ' + clsName;
    this.setAttribute("class", nameList.trim());
}
/*add some classes is classList to HTML element*/
HTMLElement.prototype.pushListClass = function(classList){
	var l = style.length;
    if(l <= 0) return;
    var css  = this.className;
    for(var x=0;x<l;x++)  css += ' '+style[x];
    this.setAttribute("class", css.trim());
}
/*add child for HTML element*/
HTMLElement.prototype.createChild = function(type,args)
{
    var subObj = document.createElement(type);
    if(args)
    {
        for(att in args) subObj.setAttribute(att,args[att]);
    }
    this.appendChild(subObj);
    return subObj;
}
// get child list what the element is all child node and extend child
HTMLElement.prototype.childList = function()
{
    var child = this.childNodes;
    var l = child.length;
    if(l>0)
    {
        for(var i=0;i<l;i++)
        {
            child.concat(child[i].childList());
        }
        return child;
    }else{
        return;
    }
}
//determine if the node is the element child return true and is not return false 
HTMLElement.prototype.isChild = function(node)
{
    try {
        var parentNode = node.parentNode;
    }catch(e){
        return false;
    }
    if(parentNode == this)
    {
        return true;
    }else{
        return this.isChild(parentNode);
    }
    return false;
}
//Now, if is IE, add HTMLElement Object to element Object
if(isIE()){
    function HTMLElement() {}
    var _createElement = document.createElement;
    var HEP = HTMLElement.prototype;
    document.createElement = function(tag)
    {
        var _elem = _createElement(tag);
        _elem.textContent = _elem.innerText;
        var cmd = '';
        for(mod in HEP)
        {
            cmd += "_elem." + mod + " = HEP." + mod  + ";";
        }
        var cmp = ptEval(cmd);
        cmp();
        return _elem;
    }
    var _getElementById = document.getElementById;
    document.getElementById = function(id)
    {
        var _elem = _getElementById(tag);
        _elem.textContent = _elem.innerText;
        var cmd = '';
        for(mod in HEP)
        {
            cmd +="_elem." + mod + " = HEP."+mod+';';
        }
        var cmp = ptEval(cmd);
        cmp();
        return _elem;
    }
    var _getElementsByTagName = document.getElementsByTagName;
    document.getElementsByTagName = function(tag)
    {
        var _arr = _getElementsByTagName(tag);
        var cmd = '';
        for(var i=0;i<_arr.length;i++)
        {
            for(mod in HEP)
            {
                cmd += "_arr[i]." + mod + " = HEP."+mod+';';
            }
            _arr[i].textContent = _arr[i].innerText;
        }
        var cmp = ptEval(cmd);
        cmp();
        return _arr;
    }
 }